home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / flilib.zip / FLIDOC.TXT < prev    next >
Text File  |  1993-02-09  |  45KB  |  1,334 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.                 Turbo C FLI Library Documentation
  13.            For FLI Files Created by Autodesk Animator
  14.  
  15.                         November 20, 1989
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. Copyright 1989-1990 Dancing Flame, San Francisco
  51. Program Code and Library by Jim Kent
  52. Documentation by Jim Kent and Heidi Brumbaugh
  53.  
  54.                        Turbo C FLI Library
  55.                         Table of Contents
  56.  
  57.  
  58.  
  59.  
  60.  
  61. 1. Introduction to the Turbo C FLI library. . . . . . . . . .   1
  62.  
  63. 2. Sample FLI programs. . . . . . . . . . . . . . . . . . . .   1
  64.      2.1 PLAY.C . . . . . . . . . . . . . . . . . . . . . . .   1
  65.      2.2 ALLFLIS.C. . . . . . . . . . . . . . . . . . . . . .   2
  66.      2.3 SLICEFLI.C . . . . . . . . . . . . . . . . . . . . .   3
  67.  
  68. 3. Usage of FLI routines. . . . . . . . . . . . . . . . . . .   5
  69.      3.1 Playback Routines. . . . . . . . . . . . . . . . . .   5
  70.      3.2 Save Routines. . . . . . . . . . . . . . . . . . . .   6
  71.  
  72. 4. VGA Graphics Support . . . . . . . . . . . . . . . . . . .   7
  73.  
  74. 5. MS-DOS Support . . . . . . . . . . . . . . . . . . . . . .   8
  75.  
  76. 6. The FLILIB header files. . . . . . . . . . . . . . . . . .  10
  77.      6.1 AAFLISAV.H . . . . . . . . . . . . . . . . . . . . .  10
  78.      6.2 AAFLI.H. . . . . . . . . . . . . . . . . . . . . . .  11
  79.      6.3 AATYPES.H  . . . . . . . . . . . . . . . . . . . . .  13
  80.      6.4 AADOS.H. . . . . . . . . . . . . . . . . . . . . . .  14
  81.      6.5 AAERR.H. . . . . . . . . . . . . . . . . . . . . . .  16
  82.      6.6 AASCREEN.H . . . . . . . . . . . . . . . . . . . . .  16
  83.  
  84. 8. Autodesk Animator files. . . . . . . . . . . . . . . . . .  18
  85.      8.1 Flic Files (.FLI). . . . . . . . . . . . . . . . . .  18
  86.      8.2 Picture Files (.GIF) . . . . . . . . . . . . . . . .  21
  87.      8.3 Cel Files (.CEL and .PIC). . . . . . . . . . . . . .  21
  88.      8.4 Palette Files (.COL) . . . . . . . . . . . . . . . .  22
  89.      8.5 Mask Files (.MSK). . . . . . . . . . . . . . . . . .  22
  90.      8.6 Text Files (.TXT). . . . . . . . . . . . . . . . . .  22
  91.      8.7 Font Files (.FNT). . . . . . . . . . . . . . . . . .  22
  92.      8.8 Polygon and Path files (.PLY). . . . . . . . . . . .  24
  93.      8.9 Optics Files (.OPT). . . . . . . . . . . . . . . . .  24
  94.      8.10 Record Files (.REC) . . . . . . . . . . . . . . . .  24
  95.  
  96.  
  97. 1. Introduction to the Turbo C FLI library
  98.  
  99.      FLI.LIB is a Turbo C large model library for manipulating 
  100. Autodesk Animator FLI files.  It also contains some general-
  101. purpose MS-DOS functions and a few VGA graphics primitives.
  102.  
  103.      The main Turbo C library is contained in the file FLI.LIB. 
  104. Additionally, you will need to include the header file AAFLI.H to
  105. read a FLI file and AAFLISAV.H to save a FLI file.  AAFLI.H will 
  106. include the additional files AATYPES.H, AADOS.H, AAERR.H and
  107. AASCREEN.H if they are not already included.  AAFLISAV.H will
  108. include AAFLI.H if it is not already included.
  109.  
  110.      The 58 source file routines to load or save a FLI are in the
  111. folder LIBSOURC; however, these modules are not necessary as they
  112. are already included in FLI.LIB.
  113.  
  114.      Your disk also includes three sample C files to load and
  115. play a FLI file.  The sample batch file which compiles these
  116. files in Turbo C is:
  117.  
  118. tcc -ml play.c fli.lib 
  119. tcc -ml allflis.c fli.lib 
  120. tcc -ml slicefli.c fli.lib
  121.  
  122.      In sum, the files you will need to use the Turbo C FLI
  123. library are:
  124.  
  125. AATYPES.H
  126. AADOS.H
  127. AAERR.H
  128. AASCREEN.H
  129. AAFLI.H
  130. AAFLISAV.H
  131. FLI.LIB
  132.  
  133. 2. Sample FLI programs
  134.  
  135.      Once the header files are included in your code and your
  136. make file is set up to properly link your program with the
  137. library, calling the high-level FLI routines is very
  138. straightforward.  In fact, the sample programs show that you can
  139. write a program to play back a FLI in about twenty-five lines --
  140. and most of that code is to verify that a VGA is connected!
  141.  
  142. 2.1 PLAY.C
  143.  
  144. This program will play a FLI file until a key is pressed.
  145.  
  146. #include "aafli.h" 
  147.  
  148. main(int argc, char *argv[]) 
  149. int ivmode; 
  150. Errval err; 
  151. if (argc != 2)   /* If command line looks wrong give a little help */
  152.  
  153.    { 
  154.    puts("Play will play a FLI file until a key is hit"); 
  155.    puts("Example usage: play pretty.fli"); 
  156.    } 
  157. else 
  158.    { 
  159.    ivmode = dos_get_vmode();  /* Get video mode to restore at exit */ 
  160.    dos_set_vmode(0x13);       /* Go into 320x200 256 color mode */ 
  161.    if (dos_get_vmode() == 0x13) 
  162.       { 
  163.       err = fli_play(argv[1]); 
  164.       dos_set_vmode(ivmode); 
  165.       if (err < AA_SUCCESS) 
  166.          puts(fli_error_message(err) ); 
  167.       } 
  168.    else 
  169.       puts("Not a VGA/MCGA display"); 
  170.    } 
  171.  
  172. 2.2 ALLFLIS.C
  173.  
  174. This program plays all the FLI files in the current directory
  175. once and exits.
  176.  
  177. #include "aafli.h" 
  178.  
  179. main() 
  180. Fndata *fn; 
  181. int ivmode; 
  182. Errval err; 
  183.  
  184. fn = dos_get_dta(); 
  185. if (dos_first("*.FLI", DOS_ATTR_NORMAL)) 
  186.    { 
  187.    ivmode = dos_get_vmode(); 
  188.    dos_set_vmode(0x13); 
  189.    if (dos_get_vmode() == 0x13) 
  190.       { 
  191.       for (;;) 
  192.          { 
  193.          if (dos_key_is()) /* check keyboard to abort between FLI's */
  194.             { 
  195.             dos_key_in(); 
  196.             break; 
  197.             } 
  198.          err = fli_once(fn->name); 
  199.          if (err < AA_SUCCESS) 
  200.             {  puts(fli_error_message(err)); 
  201.             } 
  202.          if (!dos_next()) 
  203.             break; 
  204.          } 
  205.       dos_set_vmode(ivmode); 
  206.       } 
  207.    else 
  208.       { 
  209.       puts("Not a VGA/MCGA display"); 
  210.       } 
  211.    } 
  212. else 
  213.    { 
  214.    puts("No .FLI files"); 
  215.    } 
  216.  
  217. 2.3 SLICEFLI.C
  218.  
  219. This program cuts out every other line of a FLI file, creating a
  220. new FLI.
  221.  
  222. #include "aaflisav.h" 
  223.  
  224. main(int argc, char *argv[]) 
  225. int i; 
  226. Errval err; 
  227. int ivmode; 
  228.  
  229. if (argc != 3) 
  230.    { 
  231.    puts("slicefli - a program to cut out every other line of a FLI.");
  232.    puts("   usage:  slicefli infile.fli outfile.fli"); 
  233.    exit(0); 
  234.    } 
  235. ivmode = dos_get_vmode(); 
  236. dos_set_vmode(0x13); /* To VGA/MCGA 320x200 256 color mode */ 
  237. if (dos_get_vmode() != 0x13) 
  238.    { 
  239.    puts("Not a VGA/MCGA display, sorry"); 
  240.    } 
  241. else 
  242.    { 
  243.    err = convert_fli(argv[1], argv[2]); 
  244.    if (err >= AA_SUCCESS) 
  245.       { 
  246.       fli_play(argv[2]); 
  247.       } 
  248.    dos_set_vmode(ivmode); 
  249.    if (err < AA_SUCCESS) puts(fli_error_message(err)); 
  250.    } 
  251.  
  252. /* zero out every other line of a screen */ 
  253. void slice_screen(Vscreen *s) 
  254. int i; 
  255. Pixel *p; 
  256.  
  257. p = s->p; 
  258. for (i=0; i<s->h; i+=2) 
  259.    { 
  260.    i86_bzero(p, s->bpr); 
  261.    p += 2*s->bpr; 
  262.    } 
  263.  
  264. Errval convert_fli(char *in, char *out) 
  265. Errval err = AA_SUCCESS;   /* start out optimistic! */ 
  266. Vscreen *bs; 
  267. Fli_head inhead, outhead; 
  268. Jfile infile = 0, outfile = 0; 
  269. int i; 
  270.  
  271. if ((bs = aa_alloc_mem_screen()) == NULL) 
  272.    { 
  273.    err = AA_ERR_NOMEM; 
  274.    goto EXIT; 
  275.    } 
  276. if ((infile = fli_open(in, &inhead)) < 0) 
  277.    { 
  278.    err = infile; 
  279.    goto EXIT; 
  280.    } 
  281. if ((outfile = fli_create(out, &outhead, inhead.speed)) < AA_SUCCESS) 
  282.    { 
  283.    goto EXIT; 
  284.    } 
  285. for (i=0; i<inhead.frame_count; i++) 
  286.    { 
  287.    aa_copy_screen(&aa_screen, bs); 
  288.    if ((err = fli_next_frame(infile)) < AA_SUCCESS) 
  289.       { 
  290.       goto EXIT; 
  291.       } 
  292.    slice_screen(&aa_screen); 
  293.    if ((err = fli_write_next(outfile, &outhead, &aa_screen, bs)) <
  294. AA_SUCCESS) 
  295.       { 
  296.       goto EXIT;  } 
  297.    } 
  298. if ((err = fli_end(outfile, &outhead, &aa_screen, bs)) < AA_SUCCESS) 
  299.    { 
  300.    goto EXIT; 
  301.    } 
  302. EXIT: 
  303. if (infile != 0) 
  304.    dos_close (infile); 
  305. if (outfile != 0) 
  306.    dos_close (outfile); 
  307. aa_free_mem_screen(bs); 
  308. if (err < AA_SUCCESS) 
  309.    { 
  310.    dos_delete (out); 
  311.    } 
  312. return(err); 
  313.  
  314. 3. Usage of FLI routines
  315.  
  316. 3.1 Playback Routines
  317.  
  318.      These are the main routines you will need to use to play
  319. back a FLI animation.  Note that you do not need to call some of
  320. the routines directly if you use only the high-level routines. 
  321. See the sample programs above for details.
  322.  
  323. Play a FLI on VGA screen until a key is hit. 
  324.    Errval fli_play(char *fliname) 
  325.  
  326. Play a FLI through once on VGA screen. 
  327.    Errval fli_once(char *fliname) 
  328.  
  329. Open up a FLI file, read in it's header, and check magic values
  330. to verify that it is a FLI file.  Returns open file handle on
  331. success, a negative error code on failure. 
  332.    Jfile fli_open(char *fliname, Fli_head *fh) 
  333.  
  334. Read next frame of file and update VGA screen. 
  335.    Errval fli_next_frame(Jfile ff) 
  336.  
  337. Update a screen with the next frame of a FLI file.  Note that
  338. fli_read_display_frame(ff, &aa_screen, TRUE) is the same thing as
  339. fli_next_frame(ff). 
  340.    Errval fli_read_display_frame( 
  341.       Jfile ff,            /* File handle */ 
  342.       Vscreen *v,          /* Screen to update */ 
  343.       Boolean see_colors)  /* Update hardware color registers? */ 
  344.  
  345. This routine decompresses from memory onto a screen. Use if you
  346. want to play FLI's from RAM rather than off the disk. 
  347.    void fli_uncomp( 
  348.       Vscreen *v,          /* Screen to update */ 
  349.       Fli_frame *frame,    /* Header for this frame */   
  350.       Cbuf *cbuf,          /* Compressed data for this frame */ 
  351.       Boolean see_colors)  /* Update hardware color registers? */ 
  352.  
  353. This plays a FLI from disk until the user-supplied function
  354. returns false.  The 'until' function is called every frame at
  355. least once, and as many times as possible until it's time for the
  356. next frame.  See fli_until_finished and fli_until_key. 
  357.    Errval fli_until( 
  358.       char *fliname,       /* Name of FLI to play */ 
  359.       int speed,           /* Speed to play.  If negative uses speed
  360.                            in file */ 
  361.       Boolean (*until)())  /* User-supplied function.  (See below.) */
  362.  
  363. This function returns (cur_frame < frame_count).  It's used to
  364. implement fli_once(). 
  365.    Boolean fli_until_finished( 
  366.       int cur_frame,       /* How many frames we've played */ 
  367.       int frame_count,     /* Number of frames in this FLI */ 
  368.       int cur_loop)        /* How many times have played FLI so far */
  369.  
  370. This function ignores all it's arguments, and returns FALSE only
  371. if a key is hit.  Used to implement fli_play(). 
  372.    Boolean fli_until_key( 
  373.       int cur_frame,       /* How many frames we've played */ 
  374.       int frame_count,     /* Number of frames in this FLI */ 
  375.       int cur_loop)        /* How many times have played FLI so far */
  376.  
  377. Return a descriptive name for the error code. 
  378.    char *fli_error_message(Errval err) 
  379.  
  380.  
  381. 3.2 Save Routines
  382.  
  383.      The following routines are used to save a FLI file to disk.
  384.  
  385. Start writing a FLI file.  Open file and initialize Fli_head
  386. structure. Returns file handle if everything is ok, a negative
  387. error code if not. 
  388.    Jfile fli_create( 
  389.       char *fliname,       /* Name for new FLI file */ 
  390.       Fli_head *fh,        /* Non-initialized fli-header */ 
  391.       int speed)           /* Speed (in 1/70th of a second) of FLI */ 
  392.  
  393. Write next frame to FLI file.  On first frame the value in 'last'
  394. is ignored. 
  395.    Errval fli_write_next( 
  396.       Jfile ff,            /* FLI file returned by fli_create */
  397.       Fli_head *fh,        /* Same header used by fli_create */
  398.       Vscreen *this,       /* Current frame */ 
  399.       Vscreen *last)       /* Previous frame */ 
  400.  
  401. Close FLI up:  calculate and write the ring frame, that is the
  402. difference between the first and last frame of a FLI.  Rewrite fh
  403. at start of file with final frame and byte counts.  Firstf_buf
  404. will be  loaded with the  first frame of the FLI as a side
  405. effect. 
  406.    Errval fli_end( 
  407.       Jfile ff,            /* FLI file handle */ 
  408.       Fli_head *fh,        /* Header as initialized by fli_create */ 
  409.       Vscreen *end_frame,  /* The final frame in the animation */ 
  410.       Vscreen *firstf_buf) /* A full screen buffer for 1st frame */ 
  411.  
  412. Compress a frame into comp_buf and return size after compression. 
  413. Types should be FLI_BRUN for  first frame and  FLI_LCCOMP for
  414. later frames (see AAFLI.H).  If you use fli_create,
  415. fli_write_next, and fli_end to create your  FLI files, you won't
  416. need to call this.
  417. long fli_comp_frame( 
  418.    Cbuf *comp_buf,         /* Buffer--should be CBUF_SIZE or bigger */
  419.    Pixel *last_screen,     /* Pixels from previous frame */ 
  420.    Cmap *last_cmap,        /* Colors from previous frame */ 
  421.    Pixel *this_screen,     /* Pixels from current frame */ 
  422.    Cmap *this_cmap,        /* Colors from previous frame. */ 
  423.    int type);              /* FLI_BRUN, FLI_LCCOMP etc. */  
  424.  
  425.  
  426. 4. VGA Graphics Support
  427.  
  428.      Most of these are lower-level routines you won't need to
  429. call directly; however, they are included in the library and
  430. supported here.
  431.  
  432. Sets up a 320x200 screen in memory that is structured the same as
  433. the VGA Mode 0x13. (The Vscreen structure is in AASCREEN.H.) 
  434.    Vscreen *aa_alloc_mem_screen() 
  435.  
  436. Set all pixels in screen to zero. 
  437.    void aa_clear_screen(Vscreen *s) 
  438.  
  439. Software echo of color map associated with aa_screen, the Vscreen
  440. for the VGA. 
  441.    Cmap aa_colors[256*3] 
  442. Copy the pixels and color maps from one screen to another.
  443. (Doesn't update VGA hardware registers.  Use aa_set_colors(0,
  444. 256, dest->cmap) to do that.) 
  445.    void aa_copy_screen(Vscreen *source, Vscreen *dest) 
  446.  
  447. Does nothing but call C library free(pt).  Used by all flilib
  448. functions to free aa_malloc()'d memory.   If you need to manage
  449. your own memory override these two symbols with your own. 
  450.    void aa_free(void *pt) 
  451.  
  452. Frees up memory screen gotten with aa_alloc_mem_screen(). Will
  453. check 's' for NULL before calling aa_free. 
  454.    void aa_free_mem_screen(Vscreen *s) 
  455.  
  456. Returns a AACLOCK_HZ frequency clock.  (AACLOCK_HZ is defined in
  457. AACLOCK.H as 4608 currently, but this may change. The clock
  458. management part of library is still unstable.) You must call
  459. aa_goclock() before calling this. 
  460.    long aa_getclock() 
  461.  
  462. Initialize clock. 
  463.    long aa_goclock() 
  464.  
  465. Does nothing but call C library malloc(size). See aa_free(). 
  466.    void *aa_malloc(unsigned size) 
  467.  
  468. A Vscreen structure refering to the VGA pixel memory. Useful as
  469. an argument to the many flilib functions that work on a Vscreen. 
  470.    Vscreen aa_screen 
  471.  
  472. Set some VGA color map entries from a memory table. Table is
  473. three bytes per color, one byte each for  each red, green, blue
  474. component.  The value of an rgb component should be from 0 to 63.
  475.    void aa_set_colors(int start_ix, int count, Cmap *table) 
  476.  
  477. Return when VGA is out of vertical blank. 
  478.    void aa_wait_no_vblank() 
  479.  
  480. Return when VGA is in vertical blank. 
  481.    void aa_wait_vblank() 
  482.  
  483. 5. MS-DOS Support 
  484.  
  485.      These are some general-purpose DOS routines.
  486.  
  487. That Jfile is typedef'd as an int in AADOS.H. Close a file opened
  488. with dos_open or dos_create. 
  489.    void dos_close(Jfile file) 
  490.  
  491. Tries to delete file. Returns TRUE (1) on success, FALSE (0) on
  492. failure. 
  493.    Boolean dos_delete(char *file_name) 
  494. Returns TRUE if file exists. 
  495.    Boolean dos_exists(char *file_name) 
  496.  
  497. Pattern is typically something of the form "*.FLI" and attribute
  498. DOS_ATTR_NORMAL as defined in AADOS.H.  This will return TRUE if
  499. there is a file matching the wildcard pattern and put the name of
  500. this file in the data transfer area (see dos_get_dta below).
  501.    Boolean dos_first(char *pattern, int attribute) 
  502.  
  503. Gets data transfer area from DOS for directory searches. See
  504. dos_first() and dos_next(). 
  505.    Fndata dos_get_dta(void) 
  506.  
  507. Returns current display mode. 
  508.    int dos_get_vmode() 
  509.  
  510. Returns a 16-bit keyboard scan code.  Lower 8 bits are usually
  511. ASCII values, or zero if it's a special key such as the cursor
  512. arrows. 
  513.    int dos_key_in() 
  514.  
  515. Returns TRUE if a key is ready to be read from keyboard.
  516.    Boolean dos_key_is() 
  517.  
  518. Returns a value with bits for the Shift/Alt/Control keys.
  519.    int dos_key_shift() 
  520.  
  521. Tries to make a new directory. 
  522.    Boolean dos_make_dir(char *dir_name) 
  523.  
  524. Fetches next filename matching wildcard set up by dos_first()
  525. into the data transfer area.  Returns FALSE if there are no more
  526. matches. 
  527.    Boolean dos_next() 
  528.  
  529. Tries to open a file from MS-DOS.  Returns zero if can't open
  530. file.  (Not negative as standard.) See AADOS.H for definitions of
  531. JREAD_ONLY, etc. for mode.
  532.    Jfile dos_open(char *filename, int mode) 
  533.  
  534. Read from file into memory buffer.  Note that size can be larger
  535. than 64K. 
  536.    long dos_read(Jfile file, void *buf, long size) 
  537.  
  538. Rename a file.  Return success. 
  539.    Boolean dos_rename(char *oldname, char *newname) 
  540.  
  541. This is used to implement dos_read() and dos_write() macros.
  542. Should not be called directly. 
  543.    long dos_rw(...) 
  544. Write from memory buffer into file.  Note that size can be larger
  545. than 64K. 
  546.    long dos_write(Jfile file, void *buf, long size) 
  547.  
  548. See AADOS.H for definitions of JSEEK_START etc. for mode.
  549.    long dos_seek(Jfile file, long offset, int mode) 
  550.  
  551. Set display mode.  0x13 for 256 color 320x200. 
  552.    void dos_set_vmode(int mode) 
  553.  
  554. Returns file position in bytes from beginning. 
  555.    long dos_tell(Jfile file) 
  556.  
  557.  
  558. 6. The FLILIB header files
  559.  
  560.      Following are the constants, structures and variables used
  561. in the header files you will need to play back and save a FLI
  562. file.
  563.  
  564. 6.1 AAFLISAV.H
  565.  
  566. #ifndef AAFLISAV_H 
  567. #define AAFLISAV_H 
  568.  
  569. #ifndef AAFLI_H 
  570. #include "aafli.h" 
  571. #endif /* AAFLI_H */ 
  572.  
  573. /* Compress a frame into a RAM buffer.  Return size of frame. */ 
  574. long fli_comp_frame(Cbuf *comp_buf,       /* Buffer FLI_CBUF_SIZE or
  575.                                           bigger */ 
  576.    Pixel *last_screen, Cmap *last_cmap,   /*Data from previous frame*/
  577.    Pixel *this_screen, Cmap *this_cmap,   /* Data for this frame */ 
  578.    int type);                             /* FLI_BRUN?  FLI_LC? */ 
  579.  
  580. /* Open FLI file and write out first frame.  Return file handle if
  581. things go well, error code otherwise. */ 
  582. Jfile fli_create(char *fliname,  /* file name */ 
  583.    Fli_head *fh,                 /* fli_create will initialize this */
  584.    int speed);                   /* Speed in 1/70th of a second */ 
  585.  
  586. /* Write succeeding frames of a FLI. */ 
  587. Errval fli_write_next(Jfile ff,  /* FLI file returned by fli_create */
  588.    Fli_head *fh,                 /* Same header used by fli_create */ 
  589.    Vscreen *this,                /* Current frame */ 
  590.    Vscreen *last);               /* Previous frame */ 
  591.  
  592. /* Finish up writing a FLI file. Write the 'ring frame', which is the
  593. difference between the first and last frame of a FLI.  Pass in the
  594. final frame of the FLI in last_frame.  firstf_buf will be loaded with
  595. the first frame of the FLI as a side effect.  */   Errval fli_end(Jfile ff, Fli_head *fh,  
  596.    Vscreen *end_frame, Vscreen *firstf_buf); 
  597.  
  598. #endif /* AAFLISAV_H */ 
  599.  
  600. 6.2 AAFLI.H
  601.  
  602. #ifndef AAFLI_H 
  603. #define AAFLI_H 
  604.  
  605. #ifndef AATYPES_H 
  606. #include "aatypes.h" 
  607. #endif /* AATYPES_H */ 
  608.  
  609. #ifndef AADOS_H 
  610. #include "aados.h" 
  611. #endif /* AADOS_H */ 
  612.  
  613. #ifndef AAERR_H 
  614. #include "aaerr.h" 
  615. #endif /* AAERR_H */ 
  616.  
  617. #ifndef AASCREEN_H 
  618. #include "aascreen.h" 
  619. #endif /* AASCREEN_H */ 
  620.  
  621. #define FLI_MAXFRAMES (4*1000)   /* Max number of frames. */ 
  622. #define FLIH_MAGIC 0xaf11        /* Fileheader Magic */ 
  623. #define FLIF_MAGIC 0xf1fa        /* Frame Magic */ 
  624.  
  625. typedef struct fli_head 
  626.    { 
  627.    long size; 
  628.    USHORT type;                  /* = FLIH_MAGIC */ 
  629.    USHORT frame_count; 
  630.    USHORT width; 
  631.    USHORT height; 
  632.    USHORT bits_a_pixel; 
  633.    SHORT flags; 
  634.    SHORT speed; 
  635.    long next_head; 
  636.    long frames_in_table; 
  637.    SHORT file;          /* Used by players.  Contains 0's on disk. */ 
  638.    long frame1_off;     /* Used by players.  Contains 0's on disk. */ 
  639.    long strokes;        /* how many paint strokes etc. made. */ 
  640.    long session;        /* strokes since file's been loaded. */ 
  641.    char reserved[88];   /* all zeroes on disk */ 
  642.    } Fli_head; 
  643.  
  644. /* bit defines for flags field */ 
  645. #define FLI_FINISHED 1  /* finished writing fli */ 
  646. #define FLI_LOOPED   2  /* fli has a loop frame */   
  647. typedef struct fli_frame 
  648.    { 
  649.    long size; 
  650.    USHORT type;      /* FLIF_MAGIC */ 
  651.    SHORT chunks; 
  652.    char pad[8]; 
  653.    } Fli_frame; 
  654.  
  655. typedef struct fli_chunk 
  656.    { 
  657.    long size; 
  658.    SHORT type; 
  659.    } Fli_chunk; 
  660.  
  661. typedef UBYTE Cbuf;     /* compression buffer */ 
  662.  
  663. /* size of buffer big enough to hold worst case FLI frame */ 
  664. #define FLI_CBUF_SIZE
  665. (64000L+3*AA_COLORS+2*sizeof(Fli_chunk)+sizeof(Fli_frame)) 
  666.  
  667. /* types of chunk in a fli_frame */ 
  668. #define FLI_COLOR 11 
  669. #define FLI_LC 12 
  670. #define FLI_BLACK 13 
  671. #define FLI_BRUN 15 
  672. #define FLI_COPY 16 
  673.  
  674. /** Higher-level FLI playing functions **/ 
  675. /* Decompress a single frame that's in RAM */ 
  676. void fli_uncomp(Vscreen *f,   /* The screen to update */ 
  677.    Fli_frame *frame,          /* Header for this frame */ 
  678.    Cbuf *cbuf,                /* Compressed data for this frame */
  679.    Boolean see_colors);       /* update the hardware color map? */ 
  680.  
  681. /* Read in FLI header, verify that it's a FLI file and return handle.
  682. See AAERR.H for negative return values if there are problems. */ 
  683. Jfile fli_open(char *fliname, Fli_head *fh); 
  684.  
  685. /* Read in next frame and uncompress onto screen, optionally updating
  686. hardware color palette */ 
  687. Errval fli_read_display_frame(Jfile ff, Vscreen *v, Boolean
  688. see_colors); 
  689.  
  690. /* Read and display next frame onto VGA display */ 
  691. Errval fli_next_frame(Jfile ff); 
  692.  
  693. /* Play FLI, going on forever or until 'until' function returns FALSE. 
  694. until is called with the current frame, the total frame in the FLI,
  695. and how many times have played entire FLI. */ 
  696. Errval fli_until(char *fliname, /* name of FLI to play */ 
  697.    int speed,              /* if speed negative, use speed in file */ 
  698.    AAivec until);          /* function to call to see when to stop */ 
  699.  
  700. /* The 'until' function we use to construct fli_play */ 
  701. Boolean fli_until_key(int cur_frame, int frame_count, int cur_loop); 
  702.  
  703. /* Play FLI looping forever until any key is hit */ 
  704. Errval fli_play(char *fliname); 
  705.  
  706. /* Play FLI once */ 
  707. Errval fli_once(char *fliname); 
  708.  
  709. #endif /* AAFLI_H */ 
  710.  
  711. 6.3 AATYPES.H 
  712.  
  713. #ifndef AATYPES_H 
  714. #define AATYPES_H 
  715.  
  716. #ifndef NULL 
  717. #define NULL ((void *)0L) 
  718. #endif /* NULL */ 
  719.  
  720. void *aa_malloc(unsigned); /* heap allocator */ 
  721. void aa_free(void *);      /* heap free'er */ 
  722.  
  723. #ifndef UBYTE 
  724. #define UBYTE unsigned char 
  725. #endif /* UBYTE */ 
  726. #ifndef BYTE 
  727. #define BYTE signed char 
  728. #endif /* BYTE */ 
  729. #ifndef SHORT 
  730. #define SHORT short 
  731. #endif /* SHORT */ 
  732. #ifndef SHORT 
  733. #define SHORT short 
  734. #endif /* SHORT */ 
  735. #ifndef USHORT  
  736. #define USHORT unsigned short 
  737. #endif /* USHORT */ 
  738. #ifndef LONG 
  739. #define LONG long 
  740. #endif /* LONG */ 
  741. #ifndef ULONG 
  742. #define ULONG unsigned long 
  743. #endif /* ULONG */ 
  744.  
  745. typedef void (*AAvec)();   /* pointer to a void-valued function */ 
  746. typedef int (*AAivec)();   /* pointer to an integer valued function */
  747. typedef int Boolean;      /* functions explicitly returning 0 or 1 */
  748. #define TRUE 1 
  749. #define FALSE 0 
  750.  
  751. /* useful macro to count elements in an array */ 
  752. #define Array_els(arr) (sizeof(arr)/sizeof(arr[0])) 
  753.  
  754. #endif /* AATYPES_H */ 
  755.  
  756. 6.4 AADOS.H
  757.  
  758. #ifndef AADOS_H 
  759. #define AADOS_H 
  760.  
  761. #ifndef AATYPES_H 
  762. #include "aatypes.h" 
  763. #endif /* AATYPES_H */ 
  764.  
  765. typedef int Jfile; 
  766.  
  767. dos_key_is(void);  /* return 1 if a key is ready to read, 0 if not */ 
  768. dos_key_in(void);  /* return next keyboard input.  Wait for it. */ 
  769.  
  770. /* open a file that already exists.*/ 
  771. Jfile dos_open(char *title, int mode); 
  772.  
  773. /* defines for mode parameter to dos_open  */ 
  774. #define DOS_READ_ONLY 0 
  775. #define DOS_WRITE_ONLY 1 
  776. #define DOS_READ_WRITE 2 
  777.  
  778. Jfile dos_create(char *title);   /* Create a new read/write file */ 
  779. void dos_close(Jfile f);         /* close file */ 
  780.  
  781. /* File read/write. Normally go through macros rather than use this
  782. function. */
  783. long dos_rw(Jfile f,void *buf,long size,int ah); 
  784. #define dos_read(f,b,size) dos_rw(f,b,size,0x3f) 
  785. #define dos_write(f,b,size) dos_rw(f,b,size,0x40) 
  786.  
  787. long dos_seek (Jfile f, long offset, int mode); 
  788. long dos_tell (Jfile f); 
  789.  
  790. /* defines for mode parameter to dos_seek  */ 
  791. #define DOS_SEEK_START  0 
  792. #define DOS_SEEK_RELATIVE  1 
  793. #define DOS_SEEK_END 2 
  794.  
  795. /* size of a buffer long enough to hold any MS-DOS path */ 
  796. #define DOS_PATH_SIZE 80 
  797. /* this is the data structure used by dos_first() and dos_next () in
  798. searching directories */ 
  799. typedef struct fndata  
  800.    { 
  801.    char reserved[21]; 
  802.    char attribute; 
  803.    USHORT time, date; 
  804.    long size; 
  805.    char name[13]; 
  806.    char fordos[128-43]; 
  807.    } Fndata; 
  808.  
  809. Fndata *dos_get_dta (void); /* get the DTA for directory search */ 
  810.  
  811. Boolean dos_first(char *pattern, int attributes); 
  812.  
  813. /* defines for attributes parameters */ 
  814. #define DOS_ATTR_DIR 16 
  815. #define DOS_ATTR_NORMAL  0 
  816. Boolean dos_next (void); 
  817.   
  818. /* This gets rid of the MS-DOS abort/retry/fail message. Afterwards
  819. MS-DOS acts like it was always a fail. dos_get_devlist () calls     
  820. this. */ 
  821. void dos_no_abort_retry_cancel (void);  
  822.  
  823. /* Changes device and directory. For example, name could be
  824. C:\VPAINT\FISHIES */ 
  825. Boolean dos_change_dir(char *name); 
  826.  
  827. /* Tell DOS it's time to go to another drive number.  0 = A:, 1 = B:,
  828. etc. */ 
  829. Boolean dos_change_dev(int newdev); 
  830.  
  831. /* Get current drive. 0 = A:, etc. */ 
  832. int dos_get_dev (void); 
  833.  
  834. /* Get the current device and directory into path */ 
  835. Boolean dos_get_dir (char path[DOS_PATH_SIZE]); 
  836.  
  837. /* Create a directory.  (Don't include device info.  If needed do a
  838. dos_change_dev(dev) first.) */ 
  839. Boolean dos_make_dir(char *name); 
  840.  
  841. /* Figure how much free space is on a device.  0 = current device. 1 =
  842. A:, etc. */ 
  843. long dos_dfree(int dev); 
  844.  
  845. #endif /* AADOS_H */ 
  846.  
  847. 6.5 AAERR.H
  848.  
  849. #ifndef AAERR_H 
  850. #define AAERR_H 
  851.  
  852. #define AA_SUCCESS 0             /* No Problem! */ 
  853. #define AA_ERR_MISC -1           /* Unclassified error */ 
  854. #define AA_ERR_NOMEM -2          /* Not enough memory */ 
  855. #define AA_ERR_CANTFIND -3       /* File doesn't exist */ 
  856. #define AA_ERR_CANTMAKE -4       /* Can't create file */ 
  857. #define AA_ERR_BADTYPE -5        /* File is not the right type */ 
  858. #define AA_ERR_BADDATA -6        /* File damaged internally */ 
  859. #define AA_ERR_WRONGREZ -7       /* File isn't 320x200 */ 
  860. #define AA_ERR_SHORTREAD -8      /* Not all of file is there */ 
  861. #define AA_ERR_SHORTWRITE -9     /* Couldn't write all of file */ 
  862. #define AA_ERR_SEEK  -10         /* Error during file seek */ 
  863.  
  864. typedef int Errval;   
  865. /* return something to say about error */ 
  866. char *fli_error_message(Errval err); 
  867.  
  868. #endif /* AAERR_H */ 
  869.  
  870. 6.6 AASCREEN.H
  871.  
  872. #ifndef AASCREEN_H 
  873. #define AASCREEN_H 
  874.  
  875. #ifndef AATYPES_H 
  876. #include "aatypes.h" 
  877. #endif /* AATYPES_H */ 
  878.  
  879. /* Graphics types */ 
  880. typedef unsigned char Cmap; 
  881. typedef unsigned char Pixel; 
  882. typedef unsigned char Bitplane; 
  883.  
  884. /* Constants pertaining to 320x200 256 color mode mostly */ 
  885. #define AA_VGA_SCREEN ((Pixel *)0xa0000000) 
  886. #define AA_XMAX 320 
  887. #define AA_YMAX 200 
  888. #define AA_BPR 320 
  889. #define AA_COLORS 256 
  890.  
  891. /* This structure is something we can draw on. */ 
  892. struct vscreen 
  893.    { 
  894.    int x, y;         /* upper left corner in screen coordinates */ 
  895.    unsigned w, h;    /* width, height */ 
  896.    unsigned bpr;     /* bytes per row of image p */ 
  897.    Pixel *p;         /* Starts on segment boundary */ 
  898.    Cmap *cmap;  long psize;/* size of pixels */ 
  899.    Pixel *allocedp;  /* for memory based screens only */ 
  900.    }; 
  901. typedef struct vscreen Vscreen; 
  902. extern Vscreen aa_screen; 
  903. extern Cmap aa_colors[];            /* software echo of color map */ 
  904. Boolean aa_open_vga_screen(void);   /* opens 256 color screen */ 
  905. void aa_close_vga_screen(void); 
  906.  
  907. /* Open a screen you can draw on but not see */ 
  908. Vscreen *aa_alloc_mem_screen(void); 
  909. void aa_free_mem_screen(Vscreen *ms);  /* dispose of memory screen */ 
  910. void aa_copy_screen(Vscreen *source, Vscreen *dest); 
  911. void aa_clear_screen(Vscreen *vs); 
  912.  
  913. /* Get the current video mode */ 
  914. int dos_get_vmode(void); 
  915. /* Set video mode.  Mode 0x13 is 320x200 256 color */ 
  916. void dos_set_vmode(int mode); 
  917. /* Set the VGA color map. */ 
  918. void aa_set_colors(int start, int count, Cmap *cmap);  
  919. /* Wait until in vertical blank */ 
  920. void aa_wait_vblank(void); 
  921. /* Wait until out of vertical blank */ 
  922. void aa_wait_no_vblank(void); 
  923.  
  924. #endif /* AASCREEN_H */ 
  925.  
  926.  
  927. 7. Reserved Routine Names
  928.  
  929.    What follows is a summary of low-level routines which you
  930. should not call directly as they are subject to future
  931. modification.  They are listed here only to prevent you from
  932. inadvertently duplicating the names elsewhere in your own code.
  933.  
  934.     fii_brun 
  935.     fii_fccomp 
  936.     fii_lccomp 
  937.     fii_mem_fcuncomp 
  938.     fii_reg_fcuncomp 
  939.     fii_tnsame 
  940.     fii_tnskip 
  941.     fii_unbrun 
  942.     fii_unlccomp 
  943.  
  944.     i86_bcompare 
  945.     i86_bcontrast 
  946.     i86_bcopy 
  947.     i86_bsame 
  948.     i86_bzero 
  949.     i86_enorm_ptr      i86_even_copy 
  950.     i86_make_long 
  951.     i86_make_ptr 
  952.     i86_norm_ptr 
  953.     i86_ptr_offset 
  954.     i86_ptr_seg 
  955.     i86_ptr_to_long 
  956.     i86_sysint 
  957.     i86_wcompare 
  958.     i86_wcontrast 
  959.     i86_wcopy 
  960.     i86_wsame 
  961.     i86_wzero 
  962.  
  963. 8. Autodesk Animator files
  964.  
  965.      Following is a detailed description of the FLI file format,
  966. as well as the formats for Autodesk Animator's other main file
  967. types.
  968.  
  969. 8.1 Flic Files (.FLI)
  970.  
  971.      The details of a FLI file are moderately complex, but the
  972. idea behind it is simple: don't bother storing the parts of a
  973. frame that are the same as the last frame.  Not only does this
  974. save space, but it's very quick.  It's faster to leave a pixel
  975. alone than to set it.
  976.  
  977.      A FLI file has a 128-byte header followed by a sequence of
  978. frames. The first frame is compressed using a bytewise run-length
  979. compression scheme.  Subsequent frames are stored as the
  980. difference from the previous frame.  (Occasionally the first
  981. frame and/or subsequent frames are uncompressed.)  There is one
  982. extra frame at the end of a FLI which contains the difference
  983. between the last frame and the first frame.
  984.  
  985.      The FLI header:
  986.  
  987.      byte size name      meaning
  988.      offset
  989.  
  990.      0    4    size      Length of file, for programs that want
  991.                          to read the FLI all at once if possible.
  992.      4    2    magic     Set to hex AF11.  Please use another
  993.                          value here if you change format (even to
  994.                          a different resolution) so Autodesk
  995.                          Animator won't crash trying to read it.
  996.      6    2    frames    Number of frames in FLI.  FLI files have
  997.                          a maxium length of 4000 frames.
  998.      8    2    width     Screen width (320).
  999.      10   2    height    Screen height (200).
  1000.      12   2    depth     Depth of a pixel (8). 142flagsMust be 0.
  1001.      16   2    speed     Number of video ticks between frames.
  1002.      18   4    next      Set to 0.
  1003.      22   4    frit      Set to 0.
  1004.      26   102  expand    All zeroes -- for future enhancement.
  1005.  
  1006.      Next are the frames, each of which has a header:
  1007.  
  1008.      byte size name      meaning
  1009.      offset
  1010.      0    4    size      Bytes in this frame.  Autodesk Animator
  1011.                          demands that this be less than 64K.
  1012.      4    2    magic     Always hexadecimal F1FA
  1013.      6    2    chunks    Number of 'chunks' in frame.
  1014.      8    8    expand    Space for future enhancements.  All
  1015.                          zeros.
  1016.  
  1017.      After the frame header come the chunks that make up the
  1018. frame.  First comes a color chunk if the color map has changed
  1019. from the last frame.  Then comes a pixel chunk if the pixels have
  1020. changed.  If the frame is absolutely identical to the last frame
  1021. there will be no chunks at all.
  1022.  
  1023.      A chunk itself has a header, followed by the data.  The
  1024. chunk header is:
  1025.  
  1026.      byte size name meaning
  1027.      offset
  1028.      0    4    size Bytes in this chunk.
  1029.      4    2    type Type of chunk (see below).
  1030.  
  1031.      There are currently five types of chunks you'll see in a FLI
  1032. file.
  1033.  
  1034.      number    name      meaning
  1035.      11        FLI_COLOR Compressed color map
  1036.      12        FLI_LC    Line compressed -- the most common type
  1037.                          of compression for any but the first
  1038.                          frame.  Describes the pixel difference
  1039.                          from the previous frame.
  1040.      13        FLI_BLACK Set whole screen to color 0 (only occurs
  1041.                          on the first frame).
  1042.      15        FLI_BRUN  Bytewise run-length compression -- first
  1043.                          frame only
  1044.      16        FLI_COPY  Indicates uncompressed 64000 bytes soon
  1045.                          to follow.  For those times when
  1046.                          compression just doesn't work!
  1047.  
  1048.      The compression schemes are all byte-oriented.  If the
  1049. compressed data ends up being an odd length a single pad byte is
  1050. inserted so that the FLI_COPY's always start at an even address
  1051. for faster DMA.
  1052. FLI_COLOR Chunks
  1053.      The first word is the number of packets in this chunk. This
  1054. is followed directly by the packets.  The first byte of a packet
  1055. says how many colors to skip.  The next byte says how many colors
  1056. to change.  If this byte is zero it is interpreted to mean 256. 
  1057. Next follows 3 bytes for each color to change (one each for red,
  1058. green and blue).
  1059.  
  1060. FLI_LC Chunks
  1061.      This is the most common, and alas, most complex chunk.   The
  1062. first word (16 bits) is the number of lines starting from the top
  1063. of the screen that are the same as the previous frame. (For
  1064. example, if there is motion only on the bottom line of screen
  1065. you'd have a 199 here.)  The next word is the number of lines
  1066. that do change.  Next there is the data for the changing lines
  1067. themselves.  Each line is compressed individually; among other
  1068. things this makes it much easier to play back the FLI at a
  1069. reduced size.
  1070.  
  1071.      The first byte of a compressed line is the number of packets
  1072. in this line.  If the line is unchanged from the last frame this 
  1073. is zero.  The format of an individual packet is:
  1074.  
  1075. skip_count
  1076. size_count
  1077. data
  1078.  
  1079.      The skip count is a single byte.  If more than 255 pixels
  1080. are to be skipped it must be broken into 2 packets. The size
  1081. count is also a byte.  If it is positive, that many bytes of data
  1082. follow and are to be copied to the screen.  If it's negative a
  1083. single byte follows, and is repeated -skip_count times.
  1084.  
  1085.      In the worst case a FLI_LC frame can be about 70K.  If it
  1086. comes out to be 60000 bytes or more Autodesk Animator decides
  1087. compression isn't worthwhile and saves the frame as FLI_COPY.
  1088.  
  1089. FLI_BLACK Chunks
  1090.      These are very simple.  There is no data associated with
  1091. them at all. In fact they are only generated for the first frame
  1092. in Autodesk Animator after the user selects NEW under the FLIC
  1093. menu.
  1094.  
  1095. FLI_BRUN Chunks
  1096.      These are much like FLI_LC chunks without the skips.  They
  1097. start immediately with the data for the first line, and go line-
  1098. by-line from there.  The first byte contains the number of
  1099. packets in that line.  The format for a packet is:
  1100.  
  1101. size_count
  1102. data
  1103.      If size_count is positive the data consists of a single byte
  1104. which is repeated size_count times. If size_count is negative
  1105. there are -size_count bytes of data which are copied to the
  1106. screen. In Autodesk Animator if the "compressed" data shows signs
  1107. of exceeding 60000 bytes the frame is stored as FLI_COPY instead.
  1108.  
  1109. FLI_COPY Chunks
  1110.      These are 64000 bytes of data for direct reading onto the
  1111. screen.
  1112.  
  1113. 8.2 Picture Files (.GIF)
  1114.  
  1115.      GIF (Graphics Interchange Format) is a format developed by
  1116. CompuServe Information Services.  GIF files are as close to
  1117. computer- and resolution-independent as we're likely to see in
  1118. the next few years -- there are GIF viewers available for the
  1119. Amiga, the Atari ST and 8-bit line, the Tandy Color Computer, the
  1120. Apple II, the MacIntosh, Sun workstations, PC compatibles and
  1121. most other computers with any sort of graphics display at all. 
  1122. There are also programs to convert from the more "native" file
  1123. formats (such as DEGAS on the ST, IFF on the Amiga, and MacPaint
  1124. on the Mac) to GIF.  Many of these conversion programs are
  1125. available free on Compuserve.
  1126.  
  1127.      GIF files are also fairly densely compressed, using a
  1128. modified Lempel-Zif-Welch "ladder" compression scheme similar to
  1129. that used in the popular archive programs ARC and PKZIP.  
  1130.  
  1131.      Unfortunately the nitty-gritty details of what goes into a
  1132. GIF file are rather complex, and CompuServe holds the copyright
  1133. to much of the documentation.  The PICS forum on CompuServe (type
  1134. "go pics" at any exclamation mark prompt) will provide GIF
  1135. documentation and much more in the way of useful information to
  1136. graphics programmers if you fill out a simple developer's
  1137. registration form.  Another place to look for GIF information is
  1138. the Autodesk forum on CompuServe; type "go autodesk" to learn
  1139. more.
  1140.  
  1141. 8.3 Cel Files (.CEL and .PIC)
  1142.  
  1143.      A cel file has a 32-byte header followed by the uncompressed
  1144. color map (768 bytes) followed by the uncompressed pixel image.  
  1145.  
  1146.      The header is:
  1147.      Byte Offset    Contents
  1148.            0        Magic Number - 9119 Hexadecimal
  1149.            2        Width of cel
  1150.            4        Height of cel
  1151.            6        Horizontal screen position of upper left
  1152.                     corner
  1153.            8        Vertical screen position  10Number of bits in a pixel (8)
  1154.            11       Compression type (0 for uncompressed)
  1155.            12       Size in bytes of cel image (a 4-byte long
  1156.                     word)
  1157.            16       16 bytes of zero reserved for future use.
  1158.  
  1159.      A .PIC file uses the same format, with width and height
  1160. 320x200 and screen position 0x0.  (.PIC files are generated in
  1161. Autodesk Animator if you supply a .PIC file suffix while loading
  1162. or saving a single frame.  Otherwise a GIF file is made.)
  1163.  
  1164. 8.4 Palette Files (.COL)
  1165.  
  1166.      A color file is just a binary image of the color palette. 
  1167. It consists of 768 bytes -- three bytes for each color.  Each
  1168. byte has a value from 0 to 63.  The red byte comes first, then
  1169. the green, then the blue.
  1170.  
  1171. 8.5 Mask Files (.MSK)
  1172.  
  1173.      A mask file is is an 8000-byte file.  It contains one bit
  1174. for each pixel of the screen.  It goes from left to right, top to
  1175. bottom.
  1176.  
  1177. 8.6 Text Files (.TXT)
  1178.  
  1179.    These are just ordinary ASCII files.
  1180.  
  1181. 8.7 Font Files (.FNT)
  1182.  
  1183.      My font files are a slightly strange hybrid.  They started
  1184. out as the same type of file that GEM on the ST uses.  Then some
  1185. additions were made to make it easier to convert MacIntosh fonts
  1186. to a format Autodesk Animator could use.  My apologies for
  1187. creating yet another font file format for the PC (this only makes
  1188. about 12 I know of...), especially as I don't completely
  1189. understand this one myself!
  1190.  
  1191.      A font file starts out with an 88-byte header.  This is
  1192. followed by up to three tables of various sizes:  
  1193.      Byte Offset    Name      Meaning
  1194.           0         id        Identifier.  Hex 9000 if
  1195.                               Mac-converted
  1196.           2         size      Point size of font.  Not used by
  1197.                               Animator
  1198.           4         facename  32 byte name of font.  Not used by
  1199.                               Animator
  1200.           36        ADE_lo    Lowest ASCII character in font.  
  1201.                               More often than not this is 20 hex
  1202.                               (space character).
  1203.           38        ADE_hi    Highest character in font.
  1204.           40        top_dist  unknown, unused by Animator 42asc_distunknown, unused by Animator
  1205.           44        hlf_dist  unknown, unused by Animator
  1206.           46        des_dist  unknown, unused by Animator
  1207.           48        bot_dist  unknown, unused by Animator
  1208.           50        wchr_wdt  widest character width
  1209.           52        wcel_width     widest 'cell' width (includes
  1210.                                    distance to next character)
  1211.           54        lft_ofst  unknown, unused by Animator
  1212.           56        rgt_ofst  if Mac font, is negative of Mac
  1213.                               maxKern value.  Else unknown &
  1214.                               unused.
  1215.           58        thckning  How bold is bold? Unused by
  1216.                               Animator
  1217.           60        undrline  How far down to underline? Unused
  1218.                               by Animator
  1219.           62        lghtng_m  Lightening mask. Mask for light
  1220.                               style.  Unused by Animator
  1221.           64        skewng_m  Skewing mask for italics.  Rotate
  1222.                               line on a 1 bit.  Unused by
  1223.                               Animator
  1224.           66        flags     Will swap bytes of image if bit 2
  1225.                               is non-zero.  (Part of DRI's
  1226.                               attempt to make 8086/68000 work
  1227.                               together.)
  1228.           68        hz_ofst   Unknown, unused in Animator
  1229.           72        ch_ofst   Unknown, unused in Animator
  1230.           76        fnt_dta   Unknown, unused in Animator
  1231.           80        frm_wdt   Byte width of bitmap
  1232.           82        frm_hgt   Pixel height of bitmap
  1233.           84        nxt_fnt   Unknown, unused in Animator
  1234.  
  1235.      The first table is a series of 16-bit words containing the
  1236. horizontal offset into the font bitmap image of the start of each
  1237. letter.  The width of the letter is calculated by subtracting the
  1238. offset of the next character from the offset of current
  1239. character.  There's one offset for each character in the font,
  1240. plus an extra one to give the width of the last character.  This
  1241. table is always present.
  1242.  
  1243.      The second table contains the font image.  This is a single
  1244. bit-map for the whole font (as opposed to a series of bitmaps one
  1245. for each character).  This table is always present.
  1246.  
  1247.      The third table is only present in fonts we've translated
  1248. from the MacIntosh (that is, if the id field in the header is
  1249. hexadecimal 9000).  There are two bytes for each character in the
  1250. font.  If both bytes are FF hexidecimal it is a 'missing
  1251. character', and will not be drawn.  The first byte is added to
  1252. the rgt_ofst field of the header to tell how many pixels to move
  1253. to the right (or left if the result is negative) before drawing
  1254. this character.  The second byte is how many pixels to move to
  1255. the right after drawing this character.
  1256. 8.8 Polygon and Path files (.PLY)
  1257.  
  1258.      A polygon file has an 8-byte header followed by 6 bytes for
  1259. each point of the polygon (2 bytes each x,y,z with z always zero
  1260. currently).
  1261.  
  1262.    Here is the header:
  1263.      Byte Offset    Contents
  1264.      0              16-bit point count
  1265.      2              4 bytes of zero
  1266.      6              1 if polygon closed, 0 otherwise
  1267.      7              Magic number - hex 99
  1268.  
  1269. 8.9 Optics Files (.OPT)
  1270.  
  1271.      An optics file has a 4-byte header followed by a series of
  1272. optical moves records of 50 bytes each.  Each time you click on
  1273. CONTINUE MOVE in the OPTICS menu in Autodesk Animator another
  1274. record is generated.  The header format is:
  1275.      Byte Offset    Contents
  1276.      0              Magic Number - 1A3F Hexadecimal
  1277.      2              Number of moves in this file.  16-bit count
  1278.  
  1279.    Here's the format for an individual record:
  1280.      Byte Offset    Contents
  1281.      0              4 bytes of zero (room for pointer to next
  1282.                     record when it's loaded into memory)
  1283.      4              Spin center.  x/y/z location (16 bits each)
  1284.      10             Spin axis.  x/y/z location (16 bits each)
  1285.      16             Spin turns  x/y/z (16 bits each)
  1286.      22             Intermediate turns.  Two 16-bit words.  These
  1287.                     are values for a conjugation matrix that
  1288.                     corresponds to spin axis.
  1289.      26             Size center x/y/z location (16 bits each)
  1290.      32             x multiplier -- together with x divisor
  1291.                     determines how to stretch along x
  1292.                     (horizontal) dimension
  1293.      34             x divisor
  1294.      36             y multiplier
  1295.      38             y divisor
  1296.      40             both multiplier - applied to both x and y
  1297.                     dimensions
  1298.      42             both divisor
  1299.      44             linear move x/y/z offset (16 bits each)
  1300.  
  1301. 8.10 Record Files (.REC)
  1302.  
  1303.      A record file has a 16-byte header followed by any number of
  1304. 8-byte input records.  The header format is:
  1305.      Byte Offset    Contents
  1306.      0              Magic Number - 0713 Hexadecimal 2long word (4 byte) count of number of input
  1307.                     records
  1308.      6              4 bytes of 0 
  1309.      10             1 if real-time macro, 0 otherwise
  1310.      11             5 bytes of 0
  1311.  
  1312.    The format of a input record is:
  1313.      Byte Offset    Contents
  1314.      0              Time (in 70th of second) from last record if
  1315.                     real-time, 0 otherwise.
  1316.      1              Mouse button state.  Bit 0 is left button,
  1317.                     bit 1 is right button.  (i.e. the value is 3
  1318.                     if both buttons down, 1 if only left button,
  1319.                     0 if no buttons down.)
  1320.      2              16-bit keyboard code if key pressed, 0
  1321.                     otherwise.
  1322.      4              16-bit mouse horizontal position
  1323.      6              16-bit mouse vertical position
  1324.